Skip to content

Add pubsub subscriber leaser#5210

Merged
theacodes merged 2 commits into
googleapis:masterfrom
theacodes:pubsub-subscriber-leaser
Apr 19, 2018
Merged

Add pubsub subscriber leaser#5210
theacodes merged 2 commits into
googleapis:masterfrom
theacodes:pubsub-subscriber-leaser

Conversation

@theacodes
Copy link
Copy Markdown
Contributor

This is another helper thread that maintains the leases for any messages that the current subscriber is working on. The majority of this code (notably, maintain_leases) is copied from pubsub_v1.subscriber.policy.base.BasePolicy.maintain_leases.

This is another helper thread that maintains the leases for any messages that the current subscriber is working on. The majority of this code (notably, `maintain_leases`) is copied from `pubsub_v1.subscriber.policy.base.BasePolicy.maintain_leases`.
@theacodes theacodes requested a review from crwilcox April 18, 2018 22:13
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 18, 2018
self._subscriber.drop(to_drop)

# Remove dropped items from our copy of the leased messages (they
# have already been removed from the real one by self.drop).

This comment was marked as spam.

This comment was marked as spam.


# Remove dropped items from our copy of the leased messages (they
# have already been removed from the real one by self.drop).
for item in to_drop:

This comment was marked as spam.

This comment was marked as spam.

# Create a streaming pull request.
# We do not actually call `modify_ack_deadline` over and over
# because it is more efficient to make a single request.
ack_ids = list(leased_messages.keys())

This comment was marked as spam.

This comment was marked as spam.

# period between 0 seconds and 90% of the lease. This use of
# jitter (http://bit.ly/2s2ekL7) helps decrease contention in cases
# where there are many clients.
snooze = random.uniform(0.0, p99 * 0.9)

This comment was marked as spam.

This comment was marked as spam.

leaser_ = leaser.Leaser(mock.sentinel.subscriber)

leaser_.add([
requests.LeaseRequest(ack_id='ack1', byte_size=50)])

This comment was marked as spam.

This comment was marked as spam.

@theacodes theacodes merged commit 00e618a into googleapis:master Apr 19, 2018
@theacodes theacodes deleted the pubsub-subscriber-leaser branch April 19, 2018 21:22
parthea pushed a commit that referenced this pull request Mar 2, 2026
This is another helper thread that maintains the leases for any messages that the current subscriber is working on. The majority of this code (notably, `maintain_leases`) is copied from `pubsub_v1.subscriber.policy.base.BasePolicy.maintain_leases`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants